import request from '@/utils/request.js'

//请求头添加Authrization；Basic client_id:client_secret
const auth = {
    username: 'ld-pc ',
    password: '123456'
}
const headers = {'Content-Type': 'application/x-www-form-urlencoded'}

export function login(data) {
    return request({
        headers,
        auth,
        url: `/auth/ld/login`,
        method: `post`,
        params: data
    })
}

export function getUserByUsername(data) {
    return request({
        url: `/auth/system/api/user/username`,
        method: `get`,
        params: data
    })
}

export function register(data) {
    return request({
        url: `/auth/system/api/register`,
        method: `post`,
        data,
        head:{
            'Content-Type': 'application/json'
        }
    })
}

export function getXieyi() {
    return request({
        url: `${window.location.href}/xieyi.html`,
        method: `get`,
    })
}

export function logout(accessToken) {
    return request({
        url: `auth/logout`,
        method: `get`,
        params: {
            accessToken
        }
    })
}

export function refreshToken(refreshToken) {
    return request({
        header: header,
        auth: auth,
        url: `auth/system/refresh`,
        method: `get`,
        params: {
            refreshToken
        }
    })
}
